
package ProOF.apl.problems.real.functions;

import ProOF.com.LinkerParameters;

/**
 *
 * @author Hossomi
 */
public class RealFuncCM extends aRealFunction{

	@Override
	public void parameters(LinkerParameters link) throws Exception {

	}
	
	@Override
	public int dimension() {
		return 4;
	}
	
	@Override
	public double min( int i ) {
		return -1;
	}
	
	@Override
	public double max( int i ) {
		return 1;
	}

	@Override
	public double f(double[] x) throws Exception {
		check(x);
        
        double sqSum = 0;
        double cosSum = 0;
        int n = dimension();
        
        for (double xi: x) {
            sqSum += xi*xi;
            cosSum += Math.cos(5*Math.PI*xi);
        }

        return -(0.1*cosSum - sqSum);
	}

	@Override
	public String name() {
		return "CM";
	}

	@Override
	public String description() {
		return "Cosine Mixture problem with 4 dimensions";
	}	
}
